home *** CD-ROM | disk | FTP | other *** search
- // Source Code generated by PatchMaker 1.1
- // a sick idea by Paul Baxter
- //
- // paul@paulbaxter.com
- // ProcInfo for additional traps by Matthew Dolan
-
- #if TARGET_CPU_68K && !TARGET_RT_MAC_CFM
- #error Sorry Can't do that
- #endif
-
- #include <MixedMode.h>
- #include <Appearance.h>
- #include <SpeechSynthesis.h>
- #include <A4Stuff.h>
-
- // enums for routinedescriptor
- enum {
- uppOffsetRectProcInfo = kPascalStackBased
- | STACK_ROUTINE_PARAMETER(1,kFourByteCode)
- | STACK_ROUTINE_PARAMETER(2,kTwoByteCode)
- | STACK_ROUTINE_PARAMETER(3,kTwoByteCode),
- uppPatchExtraInfo // not used
- };
-
- // Function Prototypes
- extern pascal void myOffsetRectPatch(long param1, short param2, short param3);
-
-
- // Globals to hold original routine descriptors
- RoutineDescriptorPtr gOriginalOffsetRect = nil;
-
-
- // Tell MetroWerks the procInfo for main
- ProcInfoType __procinfo = kPascalStackBased;
- pascal void main(void)
- {
- RoutineDescriptorPtr originaldesc, newdesc, unImplimentedTrapAddr;
- UInt32 size;
- UInt16 index;
- THz theZone;
-
- // get globals
- EnterCodeResource();
- // detach ourselves
- DetachResource(Get1Resource('INIT', 0));
-
- // make sure we are in the system heap
- theZone = GetZone();
- SetZone(SystemZone());
-
- unImplimentedTrapAddr = NGetTrapAddress(_Unimplemented, (_Unimplemented & 0x0800) ? ToolTrap : OSTrap);
-
- originaldesc = NGetTrapAddress(_OffsetRect, (OffsetRect & 0x0800) ? ToolTrap : OSTrap);
- if (originaldesc != unImplimentedTrapAddr) {
- if (originaldesc->goMixedModeTrap != _MixedModeMagic) {
- // Trap is 68K
- size = sizeof(RoutineDescriptor) + (sizeof(RoutineRecord) * 0);
- // allocate new descriptor
- newdesc = (RoutineDescriptorPtr) NewPtrSys(size);
- if (!newdesc) {
- Debugger();
- return;
- }
- // set fields of routine decscriptor
- newdesc->goMixedModeTrap = _MixedModeMagic;
- newdesc->version = 7;
- newdesc->routineDescriptorFlags = 0;
- newdesc->reserved1 = 0;
- newdesc->reserved2 = 0;
- newdesc->selectorInfo = 0;
- newdesc->routineCount = 0;
- index = 0;
- gOriginalOffsetRect = originaldesc;
- newdesc->routineRecords[index].procInfo = uppOffsetRectProcInfo;
- newdesc->routineRecords[index].reserved1 = 0;
- newdesc->routineRecords[index].ISA = GetCurrentArchitecture();
- newdesc->routineRecords[index].routineFlags = 4;
- newdesc->routineRecords[index].procDescriptor = (ProcPtr)myOffsetRectPatch;
- newdesc->routineRecords[index].reserved2 = 0;
- newdesc->routineRecords[index].selector = 0;
- }
- else {
- // Trap is PPC
- size = sizeof(RoutineDescriptor) + (sizeof(RoutineRecord) * originaldesc->routineCount);
- newdesc = (RoutineDescriptorPtr) NewPtrSys(size);
- if (!newdesc) {
- DebugStr("\pFailed to allocate RoutineDescriptor");
- return;
- }
- BlockMoveData(originaldesc, newdesc, size);
- gOriginalOffsetRect = originaldesc;
- index = 0;
- newdesc->routineRecords[index].procDescriptor = (ProcPtr)myOffsetRectPatch;
- newdesc->routineRecords[index].ISA = GetCurrentArchitecture();
- }
- NSetTrapAddress((UniversalProcPtr) newdesc, OffsetRect, (OffsetRect & 0x0800) ? ToolTrap : OSTrap);
- }
-
- // restore to original heap
- SetZone(theZone);
- // restore globals
- ExitCodeResource();
- }
-
-
- pascal void myOffsetRectPatch(long param1, short param2, short param3)
- {
- // Get globals
- EnterCodeResource();
-
- CALL_THREE_PARAMETER_UPP( gOriginalOffsetRect, uppOffsetRectProcInfo, param1, param2, param3);
-
- // Release globals
- ExitCodeResource();
- }
-
-